package com.company.Hillsort;

public class hillsort {

    public static void main(String[] args) {
        int[] arrs = {1,342,31,121,23,233,15,656,4545,3};


        sort(arrs);

        for (int arr : arrs) {

            System.out.println(arr);

        }

    }

    private static void sort(int[] arrs) {

        for (int Increment = arrs.length / 2 ; Increment >= 1 ; Increment = Increment / 2)
        {

            //a++实际上是改变比较组
            for (int a = Increment ; a < arrs.length ; a++)
            {

                int lingshi = arrs[a];

                int i = a;
                int j = a - Increment;

                while (j >= 0 && arrs[j] > lingshi)
                {
                    arrs[i] = arrs[j];

                    arrs[j] = lingshi;

                    i = i - Increment;

                    j = j - Increment;

                }


            }

        }

    }


}

